<template>
  <div>
    <el-dialog
      title="工作经历"
      :visible.sync="dialogVisible"
      :before-close="handleClose"
      :close-on-click-modal="false"
      width="800px"
    >
      <div class="j_b_box">
        <el-upload
          class="avatar-uploader"
          action
          :show-file-list="false"
          style="margin: 20px"
          :http-request="uploadImage"
        >
          <img v-if="form.userImg" :src="imgHost + form.userImg" class="avatar">
          <i v-else class="el-icon-plus avatar-uploader-icon" style="" />
        </el-upload>
        <ul>
          <li class="j_b_box">
            <div>
              <p>姓名</p>
              <el-input
                v-model.number="form.userName"
                placeholder="请输入姓名"
                clearablex
              />
            </div>
            <div>
              <p>生日</p>
              <el-date-picker
                v-model="form.birthday"
                type="date"
                placeholder="选择日期"
                value-format="yyyy-MM-dd"
              />
            </div>
          </li>
          <li class="j_b_box">
            <div>
              <p>地址</p>
              <el-input
                v-model.number="form.address"
                placeholder="例如：广东"
                clearablex
              />
            </div>
            <div>
              <p>电话</p>
              <el-input
                v-model.number="form.phone"
                placeholder="请输入电话"
                clearablex
              />
            </div>
          </li>
          <li>
            <div>
              <p>电子邮箱</p>
              <el-input
                v-model.number="form.mailbox"
                placeholder="请输入电子邮箱"
                clearablex
              />
            </div>
            <div>
              <p>职业</p>
              <el-input
                v-model.number="form.occupation"
                placeholder="请输入职业"
                clearablex
              />
            </div>
          </li>
          <li>
            <div style="width:100%">
              <p>个人介绍</p>
              <el-input v-model="form.introduce" type="textarea" rows="5" />
            </div>
          </li>
        </ul>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleUser">确 定</el-button>
        <el-button @click="handleClose">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { upload } from '@/fs'
import { updatePersonalInfo } from '@/api/resume'
import { Indicator } from 'mint-ui'
export default {
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    form: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      skillValue: null,
      options: []
    }
  },
  methods: {
    handleUser() {
      Indicator.open('正在编辑中，请稍后。。。')
      updatePersonalInfo(this.form).then((res) => {
        Indicator.close()
        if (res.code === 200) {
          this.$message.success(res.msg)
        } else {
          this.$message.error(res.msg)
        }
        this.$emit('handlQuery')
      })
    },
    // 取消弹窗
    handleClose() {
      this.$emit('handleClose')
    },
    uploadImage({ file }) {
      upload(file).then((res) => {
        this.form.userImg = res.code
      })
    }
  }
}
</script>
<style lang="less" scoped>
ul {
  list-style: none;
  margin: 0;
  padding: 0;
  li {
    & > div {
      width: 50%;
      padding: 10px 20px;
      p {
        line-height: 30px;
      }
      //   &:last-child {
      //       width: 100%;
      //   }
    }
    .textarea {
      width: 100%;
    }
  }
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
  border: 1px dashed #d9d9d9;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
